﻿using FlowCanvas;
using FlowCanvas.Nodes;
using NodeCanvas.Framework;
using ParadoxNotion.Design;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")]
    public class SwitchAirWall : CallableActionNodeBase
    {
        protected override void OnRegisterPorts(FlowNode node)
        {
            var o = node.AddFlowOutput("In");
            var p1 = node.AddValueInput<string>("wallName");
            var p2 = node.AddValueInput<bool>("switch");
            
            node.AddFlowInput("Out", (Flow f) => { Invoke(p1.value,p2.value); o.Call(f); });
        }

        private void Invoke(string wallName,bool unlock)
        {
            wallName = wallName.Trim();
            if (!unlock)
            {
                BlueprintUtils.UnlockAirWall(wallName);
            }
            else
            {
                BlueprintUtils.LockAirWall(wallName);
            }
        }
        
    }
}